package org.summer.lawyer.handle;

import jakarta.annotation.Resource;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.summer.lawyer.domain.vo.spuorderassign.SpuOrderAssignVo;
import org.summer.lawyer.event.SpuOrderTimeoutEvent;
import org.summer.lawyer.service.IMessageService;

/**
 *
 */
@Getter
@Slf4j
@Component
public class OrderTimeoutProcessHandle implements ApplicationListener<SpuOrderTimeoutEvent> {

    @Resource
    private SmsService smsService;
    @Resource
    private IMessageService messageService;

    private SpuOrderAssignVo spuOrderAssignVo;

    @Async
    @Override
    public void onApplicationEvent(SpuOrderTimeoutEvent event) {
        this.spuOrderAssignVo= event.getSpuOrderAssignVo();
        //站内信
        messageService.orderReturnedMsg(spuOrderAssignVo);
        //发送订单处理超时短信
        smsService.orderReturnedSms(spuOrderAssignVo.getContactPhone(),spuOrderAssignVo.getLawFirmName(),spuOrderAssignVo.getUserName());

    }
}
